package com.xd.clap.controller;

import com.xd.clap.entity.Image;
import com.xd.clap.entity.response.Result;
import com.xd.clap.services.ImageService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("image")
public class ImageController {
    @Resource
    private ImageService is;

    /**
     *  上传图片
     */
    @PostMapping("/uploadImage")
    public Result uploadImage(@RequestParam(value = "file", required = false) MultipartFile image ) {
        return is.uploadImage(image);
    }

    /**
     *  上传base64图片
     */
    @PostMapping("/uploadImageBase64")
    public Result uploadImageBase64(@RequestBody Image image ) {
        return is.uploadImageBase64(image.getUrl());
    }
}